unit probeli;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
Form1.Close;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  st:string;
  a:string;
  new:Integer;
  old:Integer;
  n:Integer;
begin
  st:=Edit1.Text;
  while ((Pos(' ',st) = 1) and (length(st)>0)) do
  Delete(st, 1, 1);
  n:=Pos(' ',st)-1;
  a:=Copy(st,1,n);
  Label2.Caption:=a+#13;
  old:=n+1;
  Delete(st,old,1);
  while ((Pos(' ',st) <> 0) and (length(st)>0)) do
  begin
  new:=Pos(' ', st);
  a:=Copy(st,old,new-old);
  Label2.Caption:=Label2.Caption+a+#13;
  old:=new;
  Delete(st, old, 1);
  end;

  new:=length(st);
  a:=Copy(st,old,new-old+1);
  Label2.Caption:=Label2.Caption+a+#13;

end;

end.
